package controller

import (
	"api/tool/captcha"
	"net/http"

	"github.com/gin-gonic/gin"
)

// GetCaptcha
// @Summary get captcha
// @Description get captcha
// @Tags Captcha
// @Accept application/json
// @Produce application/json
// @Success 200 {object} model.Response
// @Router /captcha [get]
func GetCaptcha(c *gin.Context) {
	id, b64s, err := captcha.GenerateCaptcha(4)
	if err != nil {
		ResultError(http.StatusOK, UNKOWN, Msg[UNKOWN], c)
	}
	data := map[string]string{
		"id":   id,
		"b64s": b64s,
	}
	ResultWithData(http.StatusOK, SUCCESS, Msg[SUCCESS], data, c)
}
